package com.bw.medical.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bw.medical.entity.DockerLevelEntity;
import com.bw.medical.vo.DiagnoseVo;
import com.bw.medical.vo.DoctorSumVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.Query;

import com.bw.medical.dao.DiagnoseDao;
import com.bw.medical.entity.DiagnoseEntity;
import com.bw.medical.service.DiagnoseService;


@Service("diagnoseService")
public class DiagnoseServiceImpl extends ServiceImpl<DiagnoseDao, DiagnoseEntity> implements DiagnoseService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<DiagnoseEntity> page = this.page(
                new Query<DiagnoseEntity>().getPage(params),
                new QueryWrapper<DiagnoseEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public IPage<DiagnoseEntity> getLists(Map<String, Object> params) {
        Integer patientId=null;
        if (!params.get("patientId").toString().equals(""))
        {
            patientId=Integer.valueOf(params.get("patientId").toString());
        }
        Page<DockerLevelEntity> page = new Page<>(Integer.valueOf(params.get("page").toString()), Integer.valueOf(params.get("limit").toString()));
        return baseMapper.getLists(page,patientId);
    }
    @Override
    public IPage<DiagnoseEntity> sLists(Map<String, Object> params) {
        Integer reportId=null;
        if (!params.get("reportId").toString().equals(""))
        {
            reportId=Integer.valueOf(params.get("reportId").toString());
        }
        Integer docterId=null;
        if (!params.get("docterId").toString().equals(""))
        {
            docterId=Integer.valueOf(params.get("docterId").toString());
        }
        String dateTime=null;
        if (!params.get("dateTime").toString().equals(""))
        {
            dateTime=params.get("dateTime").toString();
        }
        String patientName=null;
        if (!params.get("patientName").toString().equals(""))
        {
            patientName=params.get("patientName").toString();
        }
        String patientTel=null;
        if (!params.get("patientTel").toString().equals(""))
        {
            patientTel=params.get("patientTel").toString();
        }
        Page<DockerLevelEntity> page = new Page<>(Integer.valueOf(params.get("page").toString()), Integer.valueOf(params.get("limit").toString()));
        return baseMapper.sLists(page,reportId,docterId,dateTime,patientName,patientTel);

    }
      //查询单个患者诊断信息
    @Override
    public DiagnoseVo info(Integer reportId) {
       return baseMapper.info(reportId);
    }

    @Override
    public IPage<DiagnoseEntity> pingLi(Map<String, Object> params) {
        Integer docterId=null;
        if (!params.get("docterId").toString().equals(""))
        {
            docterId=Integer.valueOf(params.get("docterId").toString());
        }
        String dateTime=null;
        if (!params.get("dateTime").toString().equals(""))
        {
            dateTime=params.get("dateTime").toString();
        }
        Page<DockerLevelEntity> page = new Page<>(Integer.valueOf(params.get("page").toString()), Integer.valueOf(params.get("limit").toString()));
        return baseMapper.pingLi(page,docterId,dateTime);
    }

    @Override
    public IPage<DoctorSumVo> getPlist(Map<String, Object> params) {
        Page<DoctorSumVo> page = new Page<>(Integer.valueOf(params.get("page").toString()), Integer.valueOf(params.get("limit").toString()));
        return baseMapper.getPlist(page, Integer.valueOf(params.get("docterId").toString()));
    }

}